package com.fc.test.api;

import com.fc.test.model.auto.TAbbGonggao;
import com.fc.test.service.TAbbGonggaoService;
import com.fc.test.util.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/apiGonggaoController")
@Api(value = "公告")
public class ApiGonggaoController {

    @Autowired
    private TAbbGonggaoService tAbbGonggaoService;

    @ResponseBody
    @PostMapping(value="getIndexGonggao",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "首页公告")
    public String getIndexGonggao(){
        Map<String,Object> resMap = new HashMap<>();
        List<TAbbGonggao> list = tAbbGonggaoService.getIndexGonggao();
        resMap.put("data",list);
        resMap.put("success",true);
        resMap.put("msg","获取公告成功");
        return JsonUtil.jsonMapStr(resMap);
    }

    @ResponseBody
    @PostMapping(value="getGonggaoDetail",produces = {"application/json; charset=utf-8"})
    @ApiOperation(value = "公告详情")
    public String getGonggaoDetail(@ApiParam(value = "公告id") @RequestParam(value = "id") String  id){
        Map<String,Object> resMap = new HashMap<>();
        TAbbGonggao tAbbGonggao = tAbbGonggaoService.getGonggaoDetail(id);
        resMap.put("data",tAbbGonggao);
        resMap.put("success",true);
        resMap.put("msg","获取公告详情成功");
        return JsonUtil.jsonMapStr(resMap);
    }
}
